
const connection = require('../app/database');
class AuthService {
  async checkResource(tableName ,id, userId) {  // check if moment is already liked by user or
    try {
      const sql = `SELECT * FROM ${tableName} WHERE id = ? AND user_id = ?; `;  // check if moment is already liked by user or
      const [result] = await connection.execute(sql, [id, userId]);
      return result.length > 0;//true or false
    } catch (err) {
      console.log(err);
    }
  }

  // async updataMoment(content,id) {
  //   try {
  //     const sql = `UPDATE moment SET content = ? WHERE id = ? ;`;
  //     const [result] = await connection.execute(sql, [content,id]);
  //     console.log(result);
  //     return result.length > 0;//true or false
  //   } catch (err) {
  //     console.log(err);
  //   }
  // }
}
module.exports =new AuthService();